<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<fmt:setTimeZone value="GMT+8" />
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>${article.title}</title>
  <style>
    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      line-height: 1.6;
      color: #333;
      max-width: 800px;
      margin: 0 auto;
      padding: 20px;
      background: linear-gradient(135deg, #fae18e 0%, #e4edf5 100%);
    }
    .back-button {
      display: inline-block;
      margin-bottom: 20px;
      padding: 8px 15px;
      background-color: #f39c12;
      color: white;
      text-decoration: none;
      border-radius: 4px;
      font-size: 0.9em;
      transition: background-color 0.3s;
    }
    .back-button:hover {
      background-color: #e67e22;
    }
    .back-button::before {
      content: "← ";
    }
    h1 {
      color: #e67e22;
      border-bottom: 2px solid #f39c12;
      padding-bottom: 10px;
      margin-top: 0;
    }
    h2 {
      color: #d35400;
      margin-top: 30px;
    }
    .article-meta {
      color: #7f8c8d;
      font-style: italic;
      margin-bottom: 20px;
    }
    .article-content {
      background-color: white;
      padding: 20px;
      border-radius: 5px;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
      margin-bottom: 30px;
    }
    .comment {
      background-color: white;
      padding: 15px;
      margin-bottom: 15px;
      border-radius: 5px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      border-left: 3px solid #f39c12;
    }
    .comment-meta {
      color: #7f8c8d;
      font-size: 0.9em;
      margin-bottom: 5px;
    }
    form {
      background-color: white;
      padding: 20px;
      border-radius: 5px;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    input[type="text"], textarea {
      width: 100%;
      padding: 8px;
      margin: 8px 0;
      border: 1px solid #ddd;
      border-radius: 4px;
      box-sizing: border-box;
    }
    input[type="submit"] {
      background-color: #e67e22;
      color: white;
      padding: 10px 20px;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 1em;
    }
    input[type="submit"]:hover {
      background-color: #d35400;
    }
    hr {
      border: 0;
      height: 1px;
      background: #eee;
      margin: 20px 0;
    }
  </style>
</head>
<body>
<!-- 返回按钮 -->
<a href="allArticle" class="back-button">返回</a>

<h1>${article.title}</h1>
<div class="article-meta">作者: ${article.author}</div>

<div class="article-content">
  ${article.content}
</div>

<!-- 评论列表 -->
<h2>评论列表</h2>
<c:forEach items="${comments}" var="comment">
  <div class="comment">
    <div class="comment-meta">
      <strong>${comment.author}</strong> · ${comment.formattedCreated}
    </div>
    <p>${comment.content}</p>
  </div>
</c:forEach>

<!-- 评论表单 -->
<h2>发表评论</h2>
<form action="${pageContext.request.contextPath}/addComment" method="post">
  <input type="hidden" name="articleId" value="${article.id}">
  <label for="content">评论内容:</label>
  <textarea id="content" name="content" rows="4" required></textarea>
  <input type="submit" value="发布评论">
</form>
</body>
</html>